﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Enums;
namespace RoadTeam.BLL
{
    public class InspectHouseBLL : BllBase
    {

        public bool Insert(DataTable dt, string StrJson)
        {
            base.InserLog(StrJson);

            DataTable InsertRoadTeamSysData = RoadTeam.SysInterface.FactoryClass.
                CreateCsInspectHouse().GetInspectHouseDataFromRoadTeamSystem();
            DataRow dr_Insert;
            foreach (DataRow dr in dt.Rows)
            {
                dr_Insert = InsertRoadTeamSysData.NewRow();
                dr_Insert[1] = dr["InspectHouseNo"];
                dr_Insert[2] = dr["InspectHouseDate"];
                dr_Insert[3] = dr["InspectHouseUnitNo"];
                dr_Insert[4] = dr["InspectHouseSituation"];
                dr_Insert[5] = dr["InspectHouseAddress"];
                dr_Insert[6] = dr["InspectHouseContact"];
                dr_Insert[7] = dr["InspectHouseContactPhone"];
                dr_Insert[8] = dr["InspectHouseCreater"];
                dr_Insert[9] = dr["InspectHouseCreatDate"];
                dr_Insert[10] = dr["InspectHouseRemark"];
                dr_Insert[11] = dr["InspectHouseIdentifier"];
                InsertRoadTeamSysData.Rows.Add(dr_Insert);
            }
            RoadTeam.SysInterface.FactoryClass.CreateCsInspectHouse().
                InsertInspectHouseDataToRoadTeamSystem(InsertRoadTeamSysData);

            return CsInspectHouse.InsertDatatable(dt, GlobalConfig.ConnectionString);
        }

        public DataTable GetCsInspectHouseDataForEnptyTable()
        {
            SqlWhere where = new SqlWhere()
            {
                Info = new CsInspectHouse() { InspectHouseIdentifier = "-1" }
            };
            return CsInspectHouse.Select(where, GlobalConfig.ConnectionString);
        }



    }
}
